package com.autosalon.ui.banka.action;

import com.autosalon.DAO.DaoFactory;
import com.autosalon.ui.banka.Banka;
import com.autosalon.ui.banka.state.BankaStateHolder;
import com.vaadin.ui.Button.ClickEvent;

public class EditBankAction extends AbstractBankAction {

	private com.autosalon.model.Banka vybranaBanka;
	private final int id = 3;

	public EditBankAction(Banka banka) {
		super(banka);
	}

	@Override
	public void buttonClick(ClickEvent event) {

		BankaStateHolder.setState(BankaStateHolder.EDIT_BANKA_STATE, id, banka);
		Long id_banky = Long.parseLong(event.getButton().getData().toString());
		vybranaBanka = (com.autosalon.model.Banka) DaoFactory.getinstance()
				.getBanka().getById(id_banky);
		banka.setId_banky(id_banky);
		banka.getTfEditJmenoBanky().setValue(vybranaBanka.getNazevBanky());

	}

}
